package com.dd.ent.car.ui.adapter.general;

import android.content.Context;
import android.view.View;

import com.dd.ent.car.common.bean.choice.Choice;
import com.dd.ent.car.common.bean.video.Video;
import com.dd.ent.car.ui.adapter.ViewHolder;
import com.dd.ent.car.ui.adapter.base.BaseListAdapter;
import com.dd.ent.car.ui.home.templet.choice.ChoiceFeedVideoView;
import com.dd.ent.car.ui.home.templet.choice.ChoiceShortVideoView;
import com.dd.ent.car.ui.home.templet.graphic.GraphicItemView;
import com.dd.ent.car.ui.note.NoteItemLongView;
import com.dd.ent.car.ui.note.NoteItemShortView;

import java.util.Random;

/**
 * Created by huanghaibin
 * on 16-5-23.
 */
public class ChoiceAdapter extends BaseListAdapter<Choice> {
    private String systemTime;

    public ChoiceAdapter(Callback callback) {
        super(callback);
    }

    @Override
    protected void convert(ViewHolder vh, Choice item, int position) {
    }

    @Override
    protected void refreshData(ViewHolder vh, View view, Choice item, int position) {
        if (view instanceof ChoiceFeedVideoView) {
            ((ChoiceFeedVideoView) view).refreshData(position, item);
        }
        if (view instanceof NoteItemShortView){
            ((NoteItemShortView) view).refreshData(position, item.getNote());
        }
    }

    @Override
    protected int getLayoutId(int position, Choice item) {
        return -1;
    }

    @Override
    public int getViewTypeCount() {
        return 2;
    }

    @Override
    public int getItemViewType(int position) {
        return getItem(position).getDisplayType();
    }

    @Override
    protected View bindView(Context context, int position, Choice item) {
        switch (item.getDisplayType()) {
            case Choice.TYPE_VIDEO:
                return new ChoiceFeedVideoView(context);
            case Choice.TYPE_GRAPHIC:
                return new NoteItemShortView(context);
            default:
                return new ChoiceFeedVideoView(context);
        }

    }

    public void setSystemTime(String systemTime) {
        this.systemTime = systemTime;
    }


}
